import { defineStore } from 'pinia'
import axios from 'axios'

export const useLoveTalkStore = defineStore('loveTalk', {
  state() {
    return {
      talkList: [
        {
          id: 1,
          title: '只许州官放火,不许你离开我'
        }
      ]
    }
  },
  actions: {
    async getTalk() {
      const {
        data: { content: title }
      } = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json')
      this.talkList.unshift({
        id: this.talkList.length + 1,
        title
      })
    }
  }
})
